﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Dazaza.UI.Mvc
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
            name: "/",
            url: "",
            defaults: new 
            { controller = "Home", 
                action = "Index",
                pageindex = UrlParameter.Optional, 
                listtype = Models.Enums.EnumTab.Hot, 
                tab = Models.Enums.EnumTab.Hot }
                );

            routes.MapRoute(
            name: "/hot",
            url: "hot",
            defaults: 
            new {
                controller = "Home", 
                action = "Index", 
                pageindex = UrlParameter.Optional, 
                listtype = Models.Enums.EnumTab.Hot, 
                tab = Models.Enums.EnumTab.Hot }
                );

            routes.MapRoute(
            name: "/hot_p",
            url: "hot_p{pageindex}",
            defaults: 
            new { 
                controller = "Home", 
                action = "Index", 
                pageindex = 1, 
                listtype = Models.Enums.EnumTab.Hot, 
                tab = Models.Enums.EnumTab.Hot 
            },
            constraints: new { pageindex = @"[\d]*" }
                );

            routes.MapRoute(
            name: "/upcoming",
            url: "upcoming",
            defaults: new { controller = "Home", action = "Index", pageindex = UrlParameter.Optional, listtype = Models.Enums.EnumTab.Upcoming, tab = Models.Enums.EnumTab.Upcoming }
                );

            routes.MapRoute(
            name: "/upcoming_p",
            url: "upcoming_p{pageindex}",
            defaults: new { controller = "Home", action = "Index", pageindex = 1, listtype = Models.Enums.EnumTab.Upcoming, tab = Models.Enums.EnumTab.Upcoming },
            constraints: new { pageindex = @"[\d]*" }
                );


            routes.MapRoute(
            name: "/tag",
            url: "tag/{tag}",
            defaults: new { controller = "Tag", action = "Index", pageindex = UrlParameter.Optional }
                );




            routes.MapRoute(
            name: "/explore",
            url: "explore",
            defaults: new { controller = "Explore", action = "Index", pageindex = UrlParameter.Optional }
                );

            routes.MapRoute(
            name: "/submit",
            url: "submit",
            defaults: new { controller = "Submit", action = "Index", pageindex = UrlParameter.Optional }
                );

            routes.MapRoute(
            name: "/submit.aspx",
            url: "submit.aspx",
            defaults: new { controller = "Submit", action = "Index", pageindex = UrlParameter.Optional }
                );



            #region Class and Category

            routes.MapRoute(
            name: "/upcoming_{category}_p{pageindex}",
            url: "upcoming_{category}_p{pageindex}",
            defaults:
            new
            {
                controller = "Home",
                action = "Index",
                pageindex = 1,
                listtype = Models.Enums.EnumTab.Upcoming,
                tab = Models.Enums.EnumTab.Upcoming,
                category = string.Empty
            },
            constraints: new { pageindex = @"[\d]*" }
                );

            routes.MapRoute(
            name: "/upcoming_{category}",
            url: "upcoming_{category}",
            defaults:
            new
            {
                controller = "Home",
                action = "Index",
                pageindex = 1,
                listtype = Models.Enums.EnumTab.Upcoming,
                tab = Models.Enums.EnumTab.Upcoming,
                category = string.Empty
            }
                );




            routes.MapRoute(
            name: "/{category}_p",
            url: "{category}_p{pageindex}",
            defaults:
            new
            {
                controller = "Home",
                action = "Index",
                pageindex = UrlParameter.Optional,
                listtype = Models.Enums.EnumTab.Hot,
                tab = Models.Enums.EnumTab.Hot,
                category = string.Empty
            },
            constraints: new { pageindex = @"[\d]*" }
                );


            routes.MapRoute(
            name: "/{category}",
            url: "{category}",
            defaults:
            new
            {
                controller = "Home",
                action = "Index",
                pageindex = UrlParameter.Optional,
                listtype = Models.Enums.EnumTab.Hot,
                tab = Models.Enums.EnumTab.Hot,
                category = string.Empty
            }
                );




            #endregion










            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

        }
    }
}